<template>
  <div class="app-container calendar-list-container">
    <img-list v-model="imgData.dialogVisible" :img-list="imgData.imgArr" :img-index="imgData.imgIndex"></img-list>
    <div style="margin-bottom:18px;float: right;">
      <el-input style="width: 200px;" class="filter-item" placeholder="请输入机型号" v-model="pageData.params.key"></el-input>
      <el-button class="filter-item" type="primary" icon="search" @click="search()">查询</el-button>
    </div>
    <el-table border fit highlight-current-row style="width: 100%" :data="pageData.tableData">
      <el-table-column width="50" align="center" label="序号">
        <template slot-scope="scope">
          {{(pageData.params.page-1)*pageData.params.limit+(scope.$index+1)}}
        </template>
      </el-table-column>
      <el-table-column width="" align="center" label="机型号" prop="plmModelNo">
      </el-table-column>
      <el-table-column width="" align="center" label="产品名称" prop="name">
      </el-table-column>
      <el-table-column width="" align="center" label="产品图片">
        <template slot-scope="scope">
          <el-button class="" type="success" size="mini" @click="previewImg(scope.row.pdsFileModelPbsPics)">查看</el-button>
        </template>
      </el-table-column>
      <el-table-column width="" align="center" label="市场定位" prop="marketPositionDv">
      </el-table-column>
      <el-table-column width="" align="center" label="业务模式" prop="bizModelDv">
      </el-table-column>
      <el-table-column width="" align="center" label="上市年份" prop="salesYear">
      </el-table-column>
      <el-table-column width="" align="center" label="产品状态" prop="productStatusDv">
      </el-table-column>
      <el-table-column align="center" label="操作">
        <template slot-scope="scope">
          <el-button size="small" type="success" @click="$router.push({path:'pcc/detail',query:{modelPbsId:scope.row.id,productCategoryId:scope.row.productCategoryId}})">编辑</el-button>
        </template>
      </el-table-column>
    </el-table>
    <pagination :pageData="pageData.params" @pageChange="changePage" @changeSize="changeSize"></pagination>
  </div>
</template>
<script>
import { mapGetters } from 'vuex';
import * as api from '@/api/product/pcc/index';
export default {
  computed: {
    ...mapGetters(['elements', 'language', 'dict'])
  },
  data() {
    return {
      pageData: {
        params: {
          page: 1,
          limit: 10,
          total: 100,
          key: ''
        },
        tableData: []
      },
      imgData: {
        dialogVisible: false,
        imgArr: [],
        imgIndex: 0
      }
    };
  },
  created() {
    this.getList();
  },
  activated() {
    this.getList();
  },
  methods: {
    getList() {
      const params = Object.assign(
        {
          plmModelNo: this.pageData.params.key
        },
        this.pageData.params
      );
      delete params.total;
      api.getModelNotWritePcc(params).then(res => {
        console.log(res);
        if (res.code === 200) {
          this.pageData.tableData = res.data.rows;
          this.pageData.params.total = res.data.total;
        }
      });
    },
    previewImg(imgArr, index) {
      this.imgData.dialogVisible = true;
      this.imgData.imgArr = imgArr;
      this.imgData.imgIndex = index || 0;
    },
    search() {
      this.pageData.params.page = 1;
      this.getList();
    },
    changePage(pageData) {
      this.pageData.params.page = pageData.page;
      this.getList();
    },
    changeSize(pageSize) {
      this.pageData.params.limit = pageSize;
      this.pageData.params.page = 1;
      this.getList();
    }
  }
};
</script>

